import SwiftUI

struct AnimatableAttributes_Rotation : View {
    @State var angle: Double = 0
    
    var body: some View {
        VStack(spacing: 30) {
            Text("Animatable Attributes")
                .font(.largeTitle)
            
            Text("Rotation")
                .font(.title)
                .foregroundColor(.gray)
            
            Text("...")
                .font(.title3)
                .padding()
                .frame(maxWidth: .infinity)
                .background(
                    Color.indigo
                )
            
            makeDemoView()
            
            Spacer()
            
            Button(action: {
                angle += 20
            }, label: {
                Text("Rotate clockwise")
            })
            .padding(.bottom, 50)
            .font(.title)
        }
    }
    
    func makeDemoView() -> some View {
        ZStack {
            RoundedRectangle(cornerRadius: 12)
                .frame(width: 300, height: 200)
                .foregroundColor(
                    Color.orange
                )
            
            Image(systemName: "arrow.right")
                .font(.largeTitle)
                .foregroundColor(.black)
        }
        .rotationEffect(Angle(degrees: angle))
        .animation(.easeInOut, value: angle)
        .padding(.top, 200)
    }
}
